<?php

/**
 * video actions.
 *
 * @package    sf_sandbox
 * @subpackage video
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
 */
class videoActions extends autovideoActions
{

    protected function updateNewsFromRequest()
    {
        $video = $this->getRequestParameter('video');
    }

    protected function saveVideo($video)
    {
        $video->setCulture($this->getUser()->getCulture());
        $video->setTitle($this->getRequestParameter('video[title]'));
        $video->setRemark($this->getRequestParameter('video[remark]'));
        $video->setVideoSrc($this->getrequestParameter('video[video_src]'));
        $video->save();
    }

    public function executeGallery()
    {
        $c = new Criteria();
        $c->addDescendingOrderByColumn(VideoPeer::UPDATED_AT);
        $this->gallery = VideoPeer::doSelect($c);
    }

    public function executePlay()
    {
        $this->video = VideoPeer::retrieveByPk($this->getRequestParameter('id'));
    }

    public function executeEdit()
    {
        parent::executeEdit();
        //debugvar($this->video);
        if( $this->getRequest()->getMethod() == sfRequest::GET )
        {
            if( ($v = (int)$this->getRequestParameter('obj_type')) )
            {
                $this->video->setObjType($v);
                
            }
            if( ($v = (int)$this->getRequestParameter('obj_id')) )
            {
                $this->video->setObjId($v);
            }
        }
    }

    public function executeEnable()
    {
        $id = (int)$this->getRequestParameter('id');
        //debugvar('Id: ' . $id);
        $obj = VideoPeer::retrieveByPk($id);
        $this->forward404Unless($obj);

        $obj->setStatusId(MyConstants::AdStatusApproved);
        $obj->save();
        $this->redirect('video/list?id=' . $id);
    }
    public function executeDisable()
    {
        $id = (int)$this->getRequestParameter('id');
        //debugvar('Id: ' . $id);
        $obj = VideoPeer::retrieveByPk($id);
        $this->forward404Unless($obj);

        $obj->setStatusId(MyConstants::AdStatusDeleted);
        $obj->save();
        $this->redirect('video/list?id=' . $id);
    }

}
